wayland: Place subsurfaces relative to their parent
authorOlivier Fourdan <ofourdan@redhat.com>
Wed, 23 Nov 2016 13:55:40 +0000 (14:55 +0100)
committerOlivier Fourdan <ofourdan@redhat.com>
Thu, 24 Nov 2016 08:32:41 +0000 (09:32 +0100)
Now that subsurfaces can be created as child of another GdkWindow (and
not just the root window), they must be placed according to the location
of their parent, i.e. the abs_x/abs_y must be updated and taken int
account when placing and moving subsurfaces under Wayland.

https://bugzilla.gnome.org/show_bug.cgi?id=774917

gdk/gdkwindow.c
gdk/wayland/gdkwindow-wayland.c

index 3f2d526b23a0a72eb7decfc97f19e3dc70f9d3c0..83002b7243ea23c8ea99e2aec7be0fbc495a4d96 100644 (file)
@@ -796,9 +796,12 @@ recompute_visible_regions_internal (GdkWindow *private,
   old_abs_y = private->abs_y;
 
   /* Update absolute position */
-  if (gdk_window_has_impl (private))
+  if ((gdk_window_has_impl (private) &&
+       private->window_type != GDK_WINDOW_SUBSURFACE) ||
+      (gdk_window_is_toplevel (private) &&
+       private->window_type == GDK_WINDOW_SUBSURFACE))
     {
-      /* Native window starts here */
+      /* Native windows and toplevel subsurfaces start here */
       private->abs_x = 0;
       private->abs_y = 0;
     }
index 12ce61322226618b748dae5d0186dcdbfebbee67..5360c4b8272218fb75b9af5a82d9bf88064cc9fe 100644 (file)
@@ -1263,7 +1263,9 @@ gdk_wayland_window_create_subsurface (GdkWindow *window)
       impl->display_server.wl_subsurface =
         wl_subcompositor_get_subsurface (display_wayland->subcompositor,
                                          impl->display_server.wl_surface, parent_impl->display_server.wl_surface);
-      wl_subsurface_set_position (impl->display_server.wl_subsurface, window->x, window->y);
+      wl_subsurface_set_position (impl->display_server.wl_subsurface,
+                                  window->x + window->abs_x,
+                                  window->y + window->abs_y);
 
       /* In order to synchronize the initial position with the initial frame
        * content, wait with making the subsurface desynchronized until after
@@ -2592,7 +2594,9 @@ gdk_window_wayland_move_resize (GdkWindow *window,
 
           if (impl->display_server.wl_subsurface)
             {
-              wl_subsurface_set_position (impl->display_server.wl_subsurface, x, y);
+              wl_subsurface_set_position (impl->display_server.wl_subsurface,
+                                          window->x + window->abs_x,
+                                          window->y + window->abs_y);
               gdk_window_request_transient_parent_commit (window);
             }
         }